const state = {
  cacheBrands: new Map(),
  brandUuids: new Set()
}
const mutations = {
  INIT_BRANDS: (state, rows) => {
    state.cacheBrands = new Map(rows);
  },
  // 关联
  LINK_BRANDS: (state, row, key = 'uuid') => {
    state.cacheBrands.set(row[key], row);
  },
  // 取消关联
  CANCEL_BRANDS: (state, row, key = 'uuid') => {
    state.cacheBrands.delete(row[key], row);
  },
  // 批量关联
  BATCH_LINK_BRANDS: (state, rows, key = 'uuid') => {
    rows.forEach(row => {
      state.cacheBrands.set(row[key], row);
    });
  },
  // 批量取消
  BATCH_CANCEL_BRANDS: (state, rows, key = 'uuid') => {
    rows.forEach(row => {
      state.cacheBrands.delete(row[key], row);
    });
  },
  // 清空
  CLEAR_BRANDS: (state) => {
    state.cacheBrands.clear();
  },
  // 初始化关联uuid
  INIT_BRANDUUIDS: (state, uuids) => {
    state.brandUuids = new Set(uuids);
  },
  // 添加uuid
  ADD_UUID: (state, uuid) => {
    state.brandUuids.add(uuid);
  },
  // 移除uuid
  REMOVE_UUID: (state, uuid) => {
    state.brandUuids.delete(uuid);
  },
  // 批量添加uuid
  BANTCH_ADD_UUID: (state, uuids) => {
    uuids.forEach(uuid => {
      state.brandUuids.add(uuid);
    });
  },
  // 批量移除uuid
  BATCH_REMOVE_UUID: (state, uuids) => {
    uuids.forEach(uuid => {
      state.brandUuids.delete(uuid);
    });
  },
  // 清空uuid
  CLEAR_UUIDS: (state) => {
    state.brandUuids.clear();
  },
}
export {
  state,
  mutations
}
